package longcaisuyun.longcai.com.net;

import android.util.Log;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.suyunbean.AddressGuangBoBean;

/**
 * Created by Administrator on 2016/4/26.
 */
@HttpInlet(Net.CHENGGONG)
public class PostChengGong extends WHAsyPost<PostChengGong.Info> {

    public String driverid="";
    public String orderid="";

    public PostChengGong(String driverid, String orderid, AsyCallBack asyCallBack) {
        super(asyCallBack);
        this.driverid = driverid;
        this.orderid = orderid;
    }


    protected Info parser(JSONObject object) {
        Log.e("object", object.toString());
        Info info = new Info();
        try {
            info.message = object.optString("message");
            if (info.message.equals("1")) {
                info.orderid = object.optString("orderid");
                info.usetime = object.optString("usetime");
                info.percent = object.optString("percent");
                info.mobile = object.optString("mobile");
                info.week=object.optString("week");
                info.time=object.optString("time");
                for (int j = 0; j < object.getJSONArray("addresslist").length(); j++) {

                    AddressGuangBoBean addressGuangBoBean = new AddressGuangBoBean();
                    addressGuangBoBean.setAddress(object.getJSONArray("addresslist").getJSONObject(j).optString("address"));
                    addressGuangBoBean.setName(object.getJSONArray("addresslist").getJSONObject(j).optString("name"));
                    addressGuangBoBean.setPoint(object.getJSONArray("addresslist").getJSONObject(j).optString("point"));
                    info.list.add(addressGuangBoBean);
                }
                return info;

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static class Info {
        public String message;
        public String orderid;
        public String usetime;
        public String percent;
        public String mobile;
        public String week;
        public String time;
        public List<AddressGuangBoBean> list = new ArrayList<>();
    }
}
